Skip to content

Add contracttrait macro internal developer documentation#1655

Merged
leighmcculloch merged 7 commits intomainfrom
add-contracttrait-macro-docs
Dec 19, 2025
Merged

Add contracttrait macro internal developer documentation#1655
leighmcculloch merged 7 commits intomainfrom
add-contracttrait-macro-docs

Conversation

@leighmcculloch
Copy link
Copy Markdown
Member

What

Add internal documentation explaining how the #[contracttrait] macro works, including the multi-stage expansion process for handling default trait functions, the macro_rules bridge pattern, and a diagram of the system.

Why

SDK developers need to understand the macro internals to modify or debug the implementation, particularly the complex interaction between #[contracttrait], #[contractimpl], and the generated declarative macro bridge.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive internal developer documentation for the #[contracttrait] macro system, explaining the complex multi-stage expansion process used to handle default trait function implementations in Soroban smart contracts.

Key Changes

  • Documents the multi-stage macro expansion process from trait definition through final code generation
  • Explains the macro_rules! bridge pattern used to carry trait metadata from definition to implementation time
  • Includes a visual diagram and detailed stage-by-stage breakdown of the macro expansion pipeline

Comment thread soroban-sdk/docs/contracttrait.md Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@leighmcculloch leighmcculloch added this pull request to the merge queue Dec 19, 2025
@leighmcculloch leighmcculloch removed this pull request from the merge queue due to a manual request Dec 19, 2025
@leighmcculloch
Copy link
Copy Markdown
Member Author

I removed the excalidraw diagram and replaced it with a mermaidjs diagram that is defined inline in the doc.

@leighmcculloch leighmcculloch added this pull request to the merge queue Dec 19, 2025
Merged via the queue into main with commit 9415cee Dec 19, 2025
95 checks passed
@leighmcculloch leighmcculloch deleted the add-contracttrait-macro-docs branch December 19, 2025 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants